<?php


abstract class BaseFoundit extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $hinichi;


	
	protected $area;


	
	protected $longi;


	
	protected $lati;


	
	protected $type;


	
	protected $color;


	
	protected $keptin;


	
	protected $founder_nm;


	
	protected $sonota;


	
	protected $delete_yn;


	
	protected $created_at;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getHinichi($format = 'Y-m-d')
	{

		if ($this->hinichi === null || $this->hinichi === '') {
			return null;
		} elseif (!is_int($this->hinichi)) {
						$ts = strtotime($this->hinichi);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [hinichi] as date/time value: " . var_export($this->hinichi, true));
			}
		} else {
			$ts = $this->hinichi;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getArea()
	{

		return $this->area;
	}

	
	public function getLongi()
	{

		return $this->longi;
	}

	
	public function getLati()
	{

		return $this->lati;
	}

	
	public function getType()
	{

		return $this->type;
	}

	
	public function getColor()
	{

		return $this->color;
	}

	
	public function getKeptin()
	{

		return $this->keptin;
	}

	
	public function getFounderNm()
	{

		return $this->founder_nm;
	}

	
	public function getSonota()
	{

		return $this->sonota;
	}

	
	public function getDeleteYn()
	{

		return $this->delete_yn;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = FounditPeer::ID;
		}

	} 
	
	public function setHinichi($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [hinichi] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->hinichi !== $ts) {
			$this->hinichi = $ts;
			$this->modifiedColumns[] = FounditPeer::HINICHI;
		}

	} 
	
	public function setArea($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->area !== $v) {
			$this->area = $v;
			$this->modifiedColumns[] = FounditPeer::AREA;
		}

	} 
	
	public function setLongi($v)
	{

		if ($this->longi !== $v) {
			$this->longi = $v;
			$this->modifiedColumns[] = FounditPeer::LONGI;
		}

	} 
	
	public function setLati($v)
	{

		if ($this->lati !== $v) {
			$this->lati = $v;
			$this->modifiedColumns[] = FounditPeer::LATI;
		}

	} 
	
	public function setType($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->type !== $v) {
			$this->type = $v;
			$this->modifiedColumns[] = FounditPeer::TYPE;
		}

	} 
	
	public function setColor($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->color !== $v) {
			$this->color = $v;
			$this->modifiedColumns[] = FounditPeer::COLOR;
		}

	} 
	
	public function setKeptin($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->keptin !== $v) {
			$this->keptin = $v;
			$this->modifiedColumns[] = FounditPeer::KEPTIN;
		}

	} 
	
	public function setFounderNm($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->founder_nm !== $v) {
			$this->founder_nm = $v;
			$this->modifiedColumns[] = FounditPeer::FOUNDER_NM;
		}

	} 
	
	public function setSonota($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->sonota !== $v) {
			$this->sonota = $v;
			$this->modifiedColumns[] = FounditPeer::SONOTA;
		}

	} 
	
	public function setDeleteYn($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->delete_yn !== $v) {
			$this->delete_yn = $v;
			$this->modifiedColumns[] = FounditPeer::DELETE_YN;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = FounditPeer::CREATED_AT;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->hinichi = $rs->getDate($startcol + 1, null);

			$this->area = $rs->getString($startcol + 2);

			$this->longi = $rs->getFloat($startcol + 3);

			$this->lati = $rs->getFloat($startcol + 4);

			$this->type = $rs->getString($startcol + 5);

			$this->color = $rs->getString($startcol + 6);

			$this->keptin = $rs->getString($startcol + 7);

			$this->founder_nm = $rs->getString($startcol + 8);

			$this->sonota = $rs->getString($startcol + 9);

			$this->delete_yn = $rs->getString($startcol + 10);

			$this->created_at = $rs->getTimestamp($startcol + 11, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 12; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Foundit object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(FounditPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			FounditPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(FounditPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(FounditPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = FounditPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += FounditPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = FounditPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = FounditPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getHinichi();
				break;
			case 2:
				return $this->getArea();
				break;
			case 3:
				return $this->getLongi();
				break;
			case 4:
				return $this->getLati();
				break;
			case 5:
				return $this->getType();
				break;
			case 6:
				return $this->getColor();
				break;
			case 7:
				return $this->getKeptin();
				break;
			case 8:
				return $this->getFounderNm();
				break;
			case 9:
				return $this->getSonota();
				break;
			case 10:
				return $this->getDeleteYn();
				break;
			case 11:
				return $this->getCreatedAt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = FounditPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getHinichi(),
			$keys[2] => $this->getArea(),
			$keys[3] => $this->getLongi(),
			$keys[4] => $this->getLati(),
			$keys[5] => $this->getType(),
			$keys[6] => $this->getColor(),
			$keys[7] => $this->getKeptin(),
			$keys[8] => $this->getFounderNm(),
			$keys[9] => $this->getSonota(),
			$keys[10] => $this->getDeleteYn(),
			$keys[11] => $this->getCreatedAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = FounditPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setHinichi($value);
				break;
			case 2:
				$this->setArea($value);
				break;
			case 3:
				$this->setLongi($value);
				break;
			case 4:
				$this->setLati($value);
				break;
			case 5:
				$this->setType($value);
				break;
			case 6:
				$this->setColor($value);
				break;
			case 7:
				$this->setKeptin($value);
				break;
			case 8:
				$this->setFounderNm($value);
				break;
			case 9:
				$this->setSonota($value);
				break;
			case 10:
				$this->setDeleteYn($value);
				break;
			case 11:
				$this->setCreatedAt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = FounditPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setHinichi($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setArea($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setLongi($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setLati($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setType($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setColor($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setKeptin($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setFounderNm($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setSonota($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setDeleteYn($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(FounditPeer::DATABASE_NAME);

		if ($this->isColumnModified(FounditPeer::ID)) $criteria->add(FounditPeer::ID, $this->id);
		if ($this->isColumnModified(FounditPeer::HINICHI)) $criteria->add(FounditPeer::HINICHI, $this->hinichi);
		if ($this->isColumnModified(FounditPeer::AREA)) $criteria->add(FounditPeer::AREA, $this->area);
		if ($this->isColumnModified(FounditPeer::LONGI)) $criteria->add(FounditPeer::LONGI, $this->longi);
		if ($this->isColumnModified(FounditPeer::LATI)) $criteria->add(FounditPeer::LATI, $this->lati);
		if ($this->isColumnModified(FounditPeer::TYPE)) $criteria->add(FounditPeer::TYPE, $this->type);
		if ($this->isColumnModified(FounditPeer::COLOR)) $criteria->add(FounditPeer::COLOR, $this->color);
		if ($this->isColumnModified(FounditPeer::KEPTIN)) $criteria->add(FounditPeer::KEPTIN, $this->keptin);
		if ($this->isColumnModified(FounditPeer::FOUNDER_NM)) $criteria->add(FounditPeer::FOUNDER_NM, $this->founder_nm);
		if ($this->isColumnModified(FounditPeer::SONOTA)) $criteria->add(FounditPeer::SONOTA, $this->sonota);
		if ($this->isColumnModified(FounditPeer::DELETE_YN)) $criteria->add(FounditPeer::DELETE_YN, $this->delete_yn);
		if ($this->isColumnModified(FounditPeer::CREATED_AT)) $criteria->add(FounditPeer::CREATED_AT, $this->created_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(FounditPeer::DATABASE_NAME);

		$criteria->add(FounditPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setHinichi($this->hinichi);

		$copyObj->setArea($this->area);

		$copyObj->setLongi($this->longi);

		$copyObj->setLati($this->lati);

		$copyObj->setType($this->type);

		$copyObj->setColor($this->color);

		$copyObj->setKeptin($this->keptin);

		$copyObj->setFounderNm($this->founder_nm);

		$copyObj->setSonota($this->sonota);

		$copyObj->setDeleteYn($this->delete_yn);

		$copyObj->setCreatedAt($this->created_at);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new FounditPeer();
		}
		return self::$peer;
	}

} 